package com.ian.service.impl;

import com.ian.entity.Message;
import com.ian.service.TestService;
import org.springframework.security.access.prepost.PreAuthorize;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Witt
 * @version 1.0.0
 * @date 2022/5/19
 */
public class TestServiceImpl implements TestService {

    /**
     * JWT: Example 8. Authorization Configuration
     *     similarly with method security:
     *
     * @return
     */
    @Override
    @PreAuthorize("hasAuthority('SCOPE_messages:read')")
    public List<Message> getMessages() {
        List<Message> messageList = new ArrayList<>();
        messageList.add(new Message(1L, "msg1", "sum1"));
        messageList.add(new Message(2L, "msg2", "sum2"));
        return messageList;
    }
}
